package com.blog.wl2023.controller.admin;

import com.blog.wl2023.entity.*;
import com.blog.wl2023.entity.response.Result;
import com.blog.wl2023.service.admin.UpdateService;
import com.blog.wl2023.utils.note.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author wule
 * @desc 后台系统的接口
 */
@RestController
@RequestMapping("api/admin/upload")
@ResponseResult
public class AdminUploadController {

	@Autowired
	UpdateService updateService;

	/**
	 * 后台的登录校验
	 *
	 * @param user 用户数据
	 * @return 成功
	 */
	@GetMapping("userLogin")
	public Result userLogin(User user) {
		//直接匹配后台唯一用户
		return Result.ok();
	}

	/**
	 * 上传文章
	 *
	 * @param article 接收到的文章所有信息
	 * @return 保存结果
	 */
	@PostMapping("uploadBlog")
	public Result uploadBlog(@RequestBody Article article) {
		return updateService.uploadArticle(article);
	}

	/**
	 * 上传随想
	 *
	 * @param caprice 随想参数
	 * @return ok
	 */
	@PostMapping("uploadCaprice")
	public Result uploadCaprice(@RequestBody Caprice caprice) {
		return updateService.uploadCaprice(caprice);
	}


	/**
	 * 上传类型
	 *
	 * @param type 类型信息
	 * @return Result.ok()
	 */
	@PostMapping("uploadType")
	public Result uploadType(@RequestBody Type type) {
		return updateService.uploadType(type);
	}


	/**
	 * 上传类型链接信息
	 * @param treasureChests 链接信息(url,urlName,imageUrl,typeId,description)
	 * @return Result.ok()
	 */
	@PostMapping("uploadTreasureChest")
	public Result uploadTreasureChest(@RequestBody TreasureChests treasureChests) {
		return updateService.uploadTreasureChest(treasureChests);
	}

	/**
	 * 上传公告信息
	 * @param announcement  公告信息
	 * @return Result
	 */
	@PostMapping("uploadAnnouncement")
	public Result uploadAnnouncement(@RequestBody Announcement announcement) {
		return updateService.uploadAnnouncement(announcement);
	}



}
